package edu.geo.protocol;

import java.io.IOException;
import java.io.Reader;
import java.io.Writer;

import org.codehaus.jackson.map.ObjectMapper;

import edu.geo.containers.Json;

public class JsonProtocol {

	private ObjectMapper jsonMapper;
	//private static Log _LOG = LogFactory.getLog(JsonProtocol.class);

	public JsonProtocol()
	{
		jsonMapper = new ObjectMapper();
	}

	public Json read(Reader reader) throws IOException
	{
		Json geoRequest = null;
		geoRequest = jsonMapper.readValue(reader,Json.class);
		return geoRequest;
	}
	
	public void write(Writer writer, Json geoResponse)
	throws IOException
	{
		jsonMapper.writeValue(writer, geoResponse);
	}
	
}
